Conversation
added 2 commits
February 6, 2025 13:35
give information about code
add feature calculator add calculator test
moongua404
reviewed
Feb 9, 2025
moongua404
left a comment
Contributor
There was a problem hiding this comment.
되게 깔끔하고 간결한 코드를 짜신 것 같아요! 첫 주차인데도 정규형을 적극적으로 활용하셔서 더 그런 것 같아요. 1주차 미션도 수고 많으셨습니다ㅎㅎ
| assertSimpleTest(() -> | ||
| assertThatThrownBy(() -> runException("//#\\n0#30")) | ||
| .isInstanceOf(IllegalArgumentException.class) | ||
| ); |
Contributor
There was a problem hiding this comment.
반복되는 테스트는 Parameterized Test 등으로 처리할 수 있어요!
| String patternString = "^(?://(.{1})\\\\n(.*)|(?!//).*)$"; | ||
| Pattern pattern = Pattern.compile(patternString); | ||
| Matcher matcher = pattern.matcher(string); | ||
| boolean isContain = matcher.matches(); |
Contributor
There was a problem hiding this comment.
정규표현식을 씀에도 함수 분리가 안돼서 불필요하게 필드가 낭비되는 것 같아요
| throw new IllegalArgumentException("Not in rule. Can't caculate this expression"); | ||
| } | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
주석에 설명적인 부분은 README.md에 정리하고 흐름적인 부분은 함수 분리로 함수명을 통해 전달하면 좋을 것 같아요
| String[] splitExpression = expression.split(delimiter); | ||
| int sum = 0; | ||
| //소수를 표현하기 위한 .이 있으면 소수가 아니라 구분자로 인식될 것이기에 소수는 없다고 생각해도 된다. | ||
| for (int i =0; i < splitExpression.length; i++){ |
Contributor
There was a problem hiding this comment.
for 문 별다른 이유가 없다면 인덱스 접근보다 원소로 접근하는게 효율적일 것 같아요!
piamin04
reviewed
Feb 11, 2025
| int sum = 0; | ||
| //소수를 표현하기 위한 .이 있으면 소수가 아니라 구분자로 인식될 것이기에 소수는 없다고 생각해도 된다. | ||
| for (int i =0; i < splitExpression.length; i++){ | ||
| if (!splitExpression[i].matches("^[1-9][0-9]*$")) { |
There was a problem hiding this comment.
현재 splitExpression[i].matches("^[1-9][0-9]*$")로 숫자를 검증하고 있는데,
매번 정규표현식을 컴파일하는 것보다 숫자 검증을 위한 정규표현식을 별도의 메서드로 분리하는건 어떤가요..?
szoon2426
reviewed
Feb 12, 2025
| String patternString = "^(?://(.{1})\\\\n(.*)|(?!//).*)$"; | ||
| Pattern pattern = Pattern.compile(patternString); | ||
| Matcher matcher = pattern.matcher(string); | ||
| boolean isContain = matcher.matches(); |
There was a problem hiding this comment.
pattern이랑 matcher라는걸 방금 알았어요 ㄷㄷ 저는 코드로 하나하나 다짰는데 너무 쉽고 간편한 방법이 있었네요
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
calculator 기능 구현 및 test 추가